﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BattleShips.GameClients.ResponseRunners;

namespace BattleShips.GameClients {
    static class ResponseRunnerRegistry {
        static Dictionary<string, IResponseRunner> runners = new Dictionary<string, IResponseRunner>() {
            {"login", new Login() },
            {"register", new Register() },
            {"createroom", new CreateRoom() },
            {"searchroom", new SearchForARoom() },
            {"searchplayer", new SearchForAPlayer() },
            {"selectfield", new SelectField() },
            {"startgame", new StartGame() },
            {"exitgame", new ExitGame() },
            {"gooffline", new GoOffline() },
            {"opponentfound", new OpponentFound() },
            {"hitfield", new HitField() },
            {"youmiss", new YouMissThatField() },
            {"youhit", new YouHitThatField() },
            {"youwasmiss", new YouWasMissedThatField() },
            {"youwashit", new YouWasHittedThatField() },
            {"msg", new SimpleMessageResponseRunner() },
            {"endgame", new EndGame() },
            {"setturn", new SetTurn() },
            {"waitturn", new WaitTurn() },
            {"loginsuccessful", new LoginSuccessful() },
            {"registrationsuccessful", new RegistrationSuccessful() },
            {"surrender", new Surrender() },
            {"_error_" , new ErrorMessages() }
        };

        public static IResponseRunner GetReponseRunner(string name) {
            if (runners.ContainsKey(name))
                return runners[name];
            else
                throw new Exception("No response found!");
        }
    }
}
